//
//  SCMyWishController.m
//  Mutal
//
//  Created by TonyStart on 16/10/24.
//  Copyright © 2016年 com.wx. All rights reserved.
//

#import "SCMyWishController.h"
#import "SCUserInfo.h"
#import "SCMyWishCell.h"
@interface SCMyWishController ()
@property(nonatomic,strong)SCWishViewModel *wishViewModel;
@end

@implementation SCMyWishController

-(SCWishViewModel *)wishViewModel{
    if (!_wishViewModel) {
        _wishViewModel = [[SCWishViewModel alloc] init];
    }
    return _wishViewModel;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    
}
-(void)setupUI{
    self.navigationItem.title = @"我的愿望";
    
    self.tableView.estimatedRowHeight = 100;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    [self.tableView registerNib:[UINib nibWithNibName:@"SCMyWishCell" bundle:nil] forCellReuseIdentifier:@"mywishCell"];
    [self loadMyWishData];
}
-(void)loadMyWishData{
    [self.refReshC beginRefreshing:^(BOOL is_drop) {
        
    }];
    
    [self.wishViewModel requestWishsDataByUserId:[SCUserInfo defaultUser].userInfo.id finish:^{
        
        [self.tableView reloadData];
        [self.refReshC endRefreshing];
        
    }];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.wishViewModel.wishArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SCMyWishCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mywishCell" forIndexPath:indexPath];
    
    cell.wishModel = self.wishViewModel.wishArray[indexPath.row];
    
    return cell;
}




@end
